const { override, fixBabelImports, addLessLoader } = require('customize-cra');
const rewirePostcss = require('react-app-rewire-postcss');
const px2rem = require('postcss-px2rem-exclude');

module.exports = override(
    // do stuff with the webpack config...
    fixBabelImports('import', {
        libraryName: 'antd-mobile',
        style: 'css'
    }),
    addLessLoader({
        javascriptEnabled: true,
    }),
    (config, env) => {
        // 重写postcss
        rewirePostcss(config,{
            plugins: () => [
                //关键:设置px2rem
                px2rem({
                    remUnit: 108,
                    exclude: /node_modules/i,
                })
            ],
        });

        return config
    }
);
